import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);


const store = new Vuex.Store({

  state: {
    user: '',
    // 存储token
    token: '' || localStorage.getItem('token')
  },

  mutations: {
    // 修改token，并将token存入localStorage
    changeLogin(state, user) {  //这里的state对应上面状态state
      state.token = user.token;
      localStorage.setItem('token', user.token);
    }
  }
});

export default store
